<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>订单设置</span>
      </div>
      <div>
        <el-form label-position="right" label-width="100px" :model="orderConfig">
          <el-form-item label="秒杀订单超过:">
            <el-input placeholder="请输入内容" v-model="orderConfig.orderTimeout" type="number">
              <template slot="append">分</template>
            </el-input>&nbsp;未付款,订单自动关闭
          </el-form-item>
          <el-form-item label="正常订单超过:">
            <el-input placeholder="请输入内容" v-model="orderConfig.seckillTimeout" type="number">
              <template slot="append">分</template>
            </el-input>&nbsp;未付款,订单自动关闭
          </el-form-item>
          <el-form-item label="发货超过:">
            <el-input placeholder="请输入内容" v-model="orderConfig.takeTimeout" type="number">
              <template slot="append">天</template>
            </el-input>&nbsp;未收货,订单自动完成
          </el-form-item>
          <el-form-item label="订单完成超过:">
            <el-input placeholder="请输入内容" v-model="orderConfig.serviceTimeout" type="number">
              <template slot="append">天</template>
            </el-input>&nbsp;自动结束交易，不能申请售后
          </el-form-item>
          <el-form-item label="订单完成超过:">
            <el-input placeholder="请输入内容" v-model="orderConfig.commentTimeout" type="number">
              <template slot="append">天</template>
            </el-input>&nbsp;自动五星好评
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              style="margin-left: 100px;margin-top: 20px;"
              @click="updateConfig()"
            >确 定</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>
<script>
export default {
  data () {
    return {
      orderConfig: {
        id: '',
        orderTimeout: '',
        seckillTimeout: '',
        takeTimeout: '',
        serviceTimeout: '',
        commentTimeout: ''
      }
    };
  },
  created () {
    this.getConfig()
  },
  methods: {
    async getConfig () {
      const { data: resp } = await this.$http.get(
        `vi/order//order/config/detail/1`
      );
      this.orderConfig = resp.data.tbOrderConfig
    },
    async updateConfig () {

      const { data: resp } = await this.$http.put(
        `vi/order//order/config/update`,
        this.orderConfig
      );
      // 提示信息
      this.$message({
        type: "success",
        message: "保存成功"
      });
    }
  }
};
</script>
<style scoped>
.el-input {
  width: 300px;
}
.el-form {
  margin-left: 400px;
  margin-top: 40px;
}
.el-card {
  height: 600px;
}
</style>